Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncBuffer update #130

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

AsyncBuffer update #130

wants to merge 5 commits into from

Conversation

kwanUm
Copy link
Collaborator

@kwanUm kwanUm commented Oct 27, 2024

No description provided.

@@ -194,12 +194,16 @@ async def _sample_trajectories_from_envs(
self.traj_buffer.clear()

traj_ids = [uuid.uuid4().hex for _ in range(len(environments))]
await asyncio.gather(
from tqdm.asyncio import tqdm_asyncio
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we import this at the module level?

Comment on lines +202 to +206
try:
# Wait for either the batch to fill up or the timeout to expire
await asyncio.wait_for(self._batch_ready_event.wait(), timeout=self.timeout)
except asyncio.TimeoutError:
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        async with asyncio.timeout(self.timeout):
            # Wait for either the batch to fill up or the timeout to expire
            self._batch_ready_event.wait()

Alternate way of doing this using built-in asyncio.timeout

I am not sure if you need to await the wait()

await self._processed_events[request_id].wait()

async with self._lock:
print(f"Finished Request ID: {request_id}, Counter: {self._events_count[request_id]}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use logging not print

self._processed_events[request_id] = asyncio.Event()
self._events_count[request_id] = self._counter
self._counter += 1
print(f"Started Request ID: {request_id}, Counter: {self._events_count[request_id]}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use logging over print

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants